home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / cp1.zip / MYSTREAM.H < prev    next >
C/C++ Source or Header  |  1993-06-14  |  2KB  |  106 lines

  1. ===========================================================================
  2.  BBS: The Abacus * HST/DS * Potterville MI
  3. Date: 06-13-93 (12:20)             Number: 138
  4. From: DAVID NUGENT                 Refer#: NONE
  5.   To: ALL                           Recvd: NO  
  6. Subj: [07 of 12] Mystream.h          Conf: (37) C++ Langua
  7. ---------------------------------------------------------------------------
  8. // Mystream.h
  9. // iostream interface for class Myio
  10. // Defines the following classes:
  11. //  Mystreambuf     derived from streambuf - buffer management & I/O interface
  12. //  Mystreambase    base class used for initialisation & object reference
  13. //  Myiostream      customised iostream, derived from iostream/Mystreambase
  14. //
  15. // Written by David L Nugent, June 1993
  16. //
  17.  
  18. # if !defined(_Mystream_h)
  19. # define _Mystream_h 1
  20. # include <iostream.h>
  21. # include "Myio.h"
  22.  
  23.     //
  24.     // Mystreambuf
  25.     // This is the class which does all the actual I/O
  26.     // handling and (optional) buffer management
  27.     //
  28.  
  29. class Mystreambuf : public streambuf
  30. {
  31.  
  32.   public:
  33.  
  34.     Mystreambuf (Myio * mPtr);
  35.  
  36.   protected:
  37.  
  38.     virtual int overflow (int = EOF);
  39.     virtual int underflow ();
  40.     virtual int sync ();
  41.  
  42.   private:
  43.  
  44.     Myio * mptr;    // Points to the Myio instance to
  45.                     // which this stream is attached
  46.     char _back[2];  // Holder for putback
  47.  
  48. };
  49.  
  50.  
  51. class Mystreambase : public virtual ios
  52. {
  53.  
  54.   public:
  55.  
  56.     Mystreambase (Myio * mPtr);
  57.     Mystreambuf * rdbuf (void);
  58.  
  59.   protected:
  60.  
  61.     Mystreambuf mystreambuf;
  62.  
  63. };
  64.  
  65. inline
  66. Mystreambase::Mystreambase (Myio * mPtr)
  67.     : mystreambuf (mPtr)
  68. {}
  69.  
  70. inline Mystreambuf *
  71. Mystreambase::rdbuf (void)
  72.     {   return &mystreambuf;    }
  73.  
  74.  
  75. class Mystream : public Mystreambase, public iostream
  76. {
  77.  
  78.   public:
  79.  
  80.     Mystream (Myio * mPtr);
  81.     ~Mystream (void);
  82. };
  83.  
  84.     //
  85.     // class Mystream constructor
  86.     // This uses Mystreambase to set up the Mystreambuf
  87.     // which can then be used to initialise iostream.
  88.     //
  89.  
  90. inline
  91. Mystream::Mystream (Myio * m)
  92.     : Mystreambase (m), iostream (rdbuf())
  93. {}
  94.  
  95. inline
  96. Mystream::~Mystream (void)
  97.     {}
  98.  
  99. # endif     // _Mystream_h
  100.  
  101. --- MaltEd 1.0.b5
  102.  * Origin: Unique Computing Pty Ltd (3:632/348)
  103. SEEN-BY: 1/211 11/2 4 13/13 101/1 109/25 114/5 123/19 124/1 153/752 154/40
  104. SEEN-BY: 154/77 157/110 159/100 125 140 180 270 430 575 950 203/23 209/209
  105. SEEN-BY: 261/1023 280/1 390/1 396/1 5 15 2430/1 2440/5 3603/20
  106.